package liumengbaio.lolzhangyoubao.Activity.Activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.RelativeLayout;

import liumengbaio.lolzhangyoubao.R;

/**
 * Created by lanouhn on 16/9/7.
 */
public class Diamonds extends AppCompatActivity implements View.OnClickListener {
    private RelativeLayout diamond_1, diamond_6, diamond_20, diamond_30, diamond_68, diamond_128;
    private Button btn1, btn6, btn20, btn30, btn68, btn128, head_left_title;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.diamonds_activity);
        initView();
        intiData();
    }

    private void intiData() {
        btn1.setOnClickListener(this);
        btn6.setOnClickListener(this);
        btn20.setOnClickListener(this);
        btn30.setOnClickListener(this);
        btn68.setOnClickListener(this);
        btn128.setOnClickListener(this);
        head_left_title.setOnClickListener(this);
        diamond_1.setOnClickListener(this);
        diamond_6.setOnClickListener(this);
        diamond_20.setOnClickListener(this);
        diamond_30.setOnClickListener(this);
        diamond_68.setOnClickListener(this);
        diamond_128.setOnClickListener(this);
        btn1.setBackgroundResource(R.mipmap.dark_first);
        btn6.setBackgroundResource(R.mipmap.light_two);
        btn20.setBackgroundResource(R.mipmap.light_three);
        btn30.setBackgroundResource(R.mipmap.light_four);
        btn68.setBackgroundResource(R.mipmap.light_five);
        btn128.setBackgroundResource(R.mipmap.light_six);
    }

    private void initView() {
        btn1 = (Button) findViewById(R.id.btn1);
        btn6 = (Button) findViewById(R.id.btn6);
        btn20 = (Button) findViewById(R.id.btn20);
        btn30 = (Button) findViewById(R.id.btn30);
        btn68 = (Button) findViewById(R.id.btn68);
        btn128 = (Button) findViewById(R.id.btn128);
        head_left_title = (Button) findViewById(R.id.head_left_title);
        diamond_1 = (RelativeLayout) findViewById(R.id.diamond_1);
        diamond_6 = (RelativeLayout) findViewById(R.id.diamond_6);
        diamond_20 = (RelativeLayout) findViewById(R.id.diamond_20);
        diamond_30 = (RelativeLayout) findViewById(R.id.diamond_30);
        diamond_68 = (RelativeLayout) findViewById(R.id.diamond_68);
        diamond_128 = (RelativeLayout) findViewById(R.id.diamond_128);
    }

    private void onclick_bg(Button diamond_parmas, int s) {
        btn1.setBackgroundResource(R.mipmap.light_first);
        btn6.setBackgroundResource(R.mipmap.light_two);
        btn20.setBackgroundResource(R.mipmap.light_three);
        btn30.setBackgroundResource(R.mipmap.light_four);
        btn68.setBackgroundResource(R.mipmap.light_five);
        btn128.setBackgroundResource(R.mipmap.light_six);
        diamond_parmas.setBackgroundResource(s);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn1:
                onclick_bg(btn1, R.mipmap.dark_first);
                break;
            case R.id.btn6:
                onclick_bg(btn6, R.mipmap.dark_two);
                break;
            case R.id.btn20:
                onclick_bg(btn20, R.mipmap.dark_three);
                break;
            case R.id.btn30:
                onclick_bg(btn30, R.mipmap.dark_four);
                break;
            case R.id.btn68:
                onclick_bg(btn68, R.mipmap.dark_five);
                break;
            case R.id.btn128:
                onclick_bg(btn128, R.mipmap.dark_six);
                break;
            case R.id.head_left_title:
                finish();
                break;
        }
    }
}
